<?php
declare(strict_types=1);

namespace App\Http\Controllers;

use App\Library\Response;
use App\Logic\User\Service\UserScoreHistoryService;
use Illuminate\Http\JsonResponse;

class UserScoreHistoryController extends Controller
{
    public function index(): JsonResponse
    {
        return Response::success((new UserScoreHistoryService())->serviceSelect(request()->all()));
    }

    public function add(): JsonResponse
    {
        $addScore = (new UserScoreHistoryService())->serviceAdd(request()->all());
        if ($addScore["code"] == 1) {
            return Response::success(["score" => $addScore["score"], "code" => 0]);
        }
        return Response::error();
    }
}
